﻿<%@ Page Title="Thống kê tin nhắn MT" Language="C#" MasterPageFile="~/App_MasterPages/Aquarius.Master"
    AutoEventWireup="true" CodeBehind="SmsMtStatistics.aspx.cs" Inherits="SMSROUTER.UI.SmsMtStatistics"
    EnableEventValidation="false"  %>

<%@ Register Src="../UserControl/ucPaging.ascx" TagName="ucPaging" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="CssContent" runat="server">
    <style type="text/css">
        #searching span {width: 160px;display: inline-block;}
        .table2 tr.fail td{background: #FC9C9C !important;}
        .table2 tr.pending td{background: #749DC9 !important;}
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ScriptContent" runat="server">
    <script type="text/javascript">
        $(document).ready(function () {
            DatePicker("txtFromDate,txtToDate", new Date());
            ComboBox("ddlShortCode");
            SetBackgroundTable();
        });
        function SetBackgroundTable() {
            $("tr:has(td:contains('FAIL'))", "[id$=grvData]").addClass("fail");
            $("tr:has(td:contains('PENDING'))", "[id$=grvData]").addClass("pending");
        }
        function CheckSearch() {
            var fromTime = $("[id$=txtFromDate]").datepicker('getDate');
            var toTime = $("[id$=txtToDate]").datepicker('getDate');
            if (fromTime == null || toTime == null) {
                $("#ltrCheckSearch").html("Bắt buộc chọn thời điểm đầu và thời điểm cuối");
                return false;
            }
            else {
                if (toTime < fromTime) {
                    $("#ltrCheckSearch").html("Thời điểm cuối không được nhỏ hơn thời điểm đầu");
                    return false;
                }
                fromTime.setMonth(fromTime.getMonth() + 3);
                if (fromTime < toTime) {
                    $("#ltrCheckSearch").html("Giới hạn khoảng tìm kiếm là 3 tháng");
                    return false;
                }
            }
            $("#ltrCheckSearch").html("");
            return true;
        }
    </script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <div class="row-fluid">
        <div class="span12">
            <div class="head">
                <div class="isw-grid">
                </div>
                <h1>
                    Điều kiện tìm kiếm</h1>
                <div class="clear">
                </div>
            </div>
            <div class="block-fluid" style="padding: 10px 0px 5px 10px">
                <table cellpadding="0" width="100%">
                    <tbody>
                        <tr>
                            <td>Sender name</td>
                            <td>
                                <asp:DropDownList ID="ddlShortCode" runat="server" />
                            </td>
                            <td> Số điện thoại</td>
                            <td><asp:TextBox ID="txtPhoneNumber" runat="server" /></td>
                        </tr>
                        <tr>
                            <td> Thời gian gửi</td>
                            <td><asp:TextBox ID="txtFromDate" runat="server" /></td>
                            <td> đến ngày</td>
                            <td>
                                <asp:TextBox ID="txtToDate" runat="server" />
                                <span style="color:Red"> (Khoảng tìm kiếm tối đa 3 tháng)</span>
                            </td>
                        </tr>
                        <tr>
                            <td>Trạng thái tin nhắn</td>
                            <td>
                                <asp:DropDownList ID="ddlStatus" runat="server">
                                    <asp:ListItem Value="" Text="" />
                                    <asp:ListItem Value="SENT" Text="SENT" />
                                    <asp:ListItem Value="PENDING" Text="PENDING" />
                                    <asp:ListItem Value="FAIL" Text="FAIL" />
                                </asp:DropDownList>
                            </td>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                        </tr>
                    </tbody>
                </table>
                <div style="text-align: center">
                    <asp:Button ID="btnSearch" runat="server" Text="Tìm kiếm" OnClick="btnSearch_Click"
                        CssClass="btn" OnClientClick="return CheckSearch();" />
                </div>
                <div style="text-align: center; color: Red">
                    <span id="ltrCheckSearch"></span>
                </div>
            </div>
        </div>
    </div>
    <div class="row-fluid">
        <div class="span12">
            <div class="head">
                <div class="isw-grid">
                </div>
                <h1>Thống kê</h1>
                <ul class="buttons">
                    <li><asp:LinkButton ID="btnRetry" runat="server" ToolTip="Retry dữ liệu" CssClass="isw-ok" OnClick="btnRetry_Click" OnClientClick="return CheckRetry();" /></li>
                </ul>
                <div class="clear">
                </div>
            </div>
            <div class="block-fluid table-sorting">
                <div role="grid" class="dataTables_wrapper" id="tSortable_wrapper">
                    <div class="dataTables_length">
                        <label>
                            Hiển thị
                            <asp:DropDownList ID="tSortable_length" size="1" aria-controls="tSortable" runat="server"
                                OnSelectedIndexChanged="tSortable_length_SelectedIndexChanged" AutoPostBack="true" onchange="if(!CheckSearch()) return false;">
                                <asp:ListItem Value="50" Selected="True">50</asp:ListItem>
                                <asp:ListItem Value="100">100</asp:ListItem>
								<asp:ListItem Value="150">150</asp:ListItem>
								<asp:ListItem Value="200">200</asp:ListItem>
								<asp:ListItem Value="300">300</asp:ListItem>
                            </asp:DropDownList>
                            dòng</label>
                    </div>
                    <div>
                        <uc1:ucPaging ID="pagingtop" runat="server"  Visible="false"/>
                    </div>
                    <asp:GridView ID="grvData" runat="server" CssClass="dataTables_wrapper table2 dataTable" aria-describedby="tSortable_info"
                        AutoGenerateColumns="false" ShowHeaderWhenEmpty="true">
                        <Columns>
                            <asp:TemplateField HeaderText="STT" ItemStyle-CssClass="STT">
                                <ItemTemplate>
                                    <%#(Container.DataItemIndex + 1) + (pagingtop.CurrentPage - 1) * pagingtop.PageSize%>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField HeaderText="Sender name" DataField="ShortCode" ItemStyle-CssClass="Phone"/>
                            <asp:BoundField HeaderText="Số điện thoại" DataField="DestAddr" ItemStyle-CssClass="Phone"/>
                            <asp:BoundField HeaderText="Tin nhắn" DataField="Message" />
                            <asp:TemplateField HeaderText="Độ dài mẫu tin" ItemStyle-CssClass="DateTime">
                                <ItemTemplate>
                                    <%#Eval("Message").ToString().GetMessageCount()%>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField HeaderText="Thời gian gửi" DataField="SentTime" DataFormatString="{0:dd/MM/yyyy HH:mm:ss}" ItemStyle-CssClass="DateTime2"/>
                            <asp:BoundField HeaderText="Trạng thái tin nhắn" DataField="Status" ItemStyle-Wrap="false" ItemStyle-CssClass="width1"/>
                            <asp:TemplateField HeaderText="<input type='checkbox' id='chkCheckAll' onclick='CheckAllCheckBox(this);'/>" ItemStyle-CssClass="CheckBox">
                                <ItemTemplate>
                                    <asp:CheckBox ID="chkItem" runat="server" ToolTip='<%#Eval("SmsOutID")%>' Visible='<%#Eval("Status").Equals("FAIL")%>' />
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
                    <div class="dataTables_info" id="tSortable_info">
                        <asp:Literal ID="ltrInfo" runat="server" />
                    </div>
                    <div class="dataTables_paginate paging_full_numbers" id="tSortable_paginate">
                        <uc1:ucPaging ID="pagingbottom" runat="server"  Visible="false"/>
                    </div>
                </div>
                <div class="clear">
                </div>
            </div>
        </div>
    </div>
</asp:Content>
